fix(inward): restore discharge notification fixes, room management enhancements (Closes #21257, #21389, #21390, #21391)#21456
Conversation
…pt, and audit logging (Closes #21257) - Fix unresponsive Discharge/Cancel buttons on inward_patient_room_details.xhtml by switching from ajax=false to AJAX with process="@this" update="@Form" - Fix patientRoom vs pR bug in RoomChangeController.dischargeWithCurrentTime() where indexOf used the List field instead of the method parameter - Add rendered toggle between Discharge and Cancel buttons based on room discharge state - Add success/error messages after discharge and cancel actions - Add current room listing to admission_profile.xhtml Room Management panel showing active PatientRoom/GuardianRoom with admitted time and View link - Add inward_room_discharge_receipt.xhtml receipt page with Print, Print Previous, and Inpatient Dashboard navigation - Add JS confirmation dialogs (p:confirm) for discharge and cancel actions - Add audit event logging (AuditEvent) for room discharge and cancel via AuditEventApplicationController - Fix cancel to properly clear dischargedAt field Co-Authored-By: Claude <noreply@anthropic.com>
…anagement actions (Closes #21257) - Add privilege checks to all Room Management buttons on admission_profile.xhtml (InwardRoomRoomChange, InwardRoomGurdianRoomChange, InwardRoomRoomOccupency) - Add new "Add New Room" and "Add Guardian Room" buttons to dashboard - Add audit event logging (AuditEvent) to all room operations: admitRoom, change, addNewRoom, changeGurdianRoom, discharge, remove, removeRoom, removeGuardianRoom - Add notification support for room admit, room change, and discharge cancel via new trigger types INWARD_PATIENT_ROOM_ADDED and INWARD_PATIENT_ROOM_CHANGED - Extend NotificationController with createInwardRoomAdmitNotifications, createInwardRoomChangeNotifications, createInwardRoomDischargeCancelNotifications Co-Authored-By: Claude <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 15 minutes and 57 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis PR extends inward admission workflows with event tracking and discharge receipt functionality. It adds trigger types and notification handlers for room operations, integrates audit event logging into room management workflows, provides an API to query active room assignments, and adds UI to display current rooms in admission profiles and a standalone discharge receipt page. ChangesRoom Event Notifications, Audit Logging, and Discharge Receipt
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/java/com/divudi/bean/inward/AdmissionController.java`:
- Around line 785-787: In getActivePatientRooms in AdmissionController, stop
swallowing all Exceptions: log the caught Exception with full details (e.g.,
using the class logger or a Logger instance) and surface a recoverable error
signal instead of returning an empty list — either rethrow a checked or
unchecked application-level exception (or return an Optional/Result wrapper) so
callers can detect the failure; if no logger exists, add a private static final
Logger and use logger.error("Failed to fetch active patient rooms", e) before
throwing or returning the error result.
In `@src/main/java/com/divudi/bean/inward/RoomChangeController.java`:
- Around line 420-425: The code currently calls
auditEventApplicationController.logAuditEvent(auditEvent) twice which enqueues
the same AuditEvent twice; remove the first logAuditEvent call and instead set
the final state on the AuditEvent (call auditEvent.setEventStatus("Completed")
and auditEvent.setEventDuration(new Date().getTime() -
auditEvent.getEventDataTime().getTime())) before invoking
auditEventApplicationController.logAuditEvent(auditEvent) once so only the
completed event is enqueued.
In `@src/main/webapp/inward/admission_profile.xhtml`:
- Around line 541-547: Add stable id attributes to each actionable
p:commandButton in the room-management UI so JSF and automation hooks can
reliably target them; specifically, add an id to the p:commandButton that
invokes admissionController.navigateToPatientRoomDetails() (e.g.,
id="viewPatientRoomDetailsBtn") and likewise add clear, unique ids to the other
actionable buttons in the same fragment (the buttons in the other mentioned
ranges) using descriptive names (e.g., id="editRoomBtn", id="assignRoomBtn",
id="manageRoomBtn") so each button has a stable, semantic id attribute.
- Around line 536-538: The f:convertDateTime used to render #{room.admittedAt}
should pin the timezone to Asia/Colombo to prevent JVM/server timezone drift;
update the <f:convertDateTime> element (the converter attached to the
h:outputText for #{room.admittedAt}) to include timeZone="Asia/Colombo" (e.g.,
<f:convertDateTime pattern="dd MMM yyyy HH:mm" timeZone="Asia/Colombo"/>).
In `@src/main/webapp/inward/inward_room_discharge_receipt.xhtml`:
- Around line 52-58: The "Print Previous" p:commandButton is currently wired to
onclick="printReceipt()", duplicating the main Print action; either implement
the intended previous-receipt behavior by changing the onclick to a new handler
(e.g., onclick="printPreviousReceipt()") and add/implement the JavaScript
function printPreviousReceipt() to fetch and render the prior receipt, or if
you’re not implementing retrieval now, rename the button label (value="Print
Previous") to a non-misleading name like "Print Copy" (and update any
tooltip/title) so its behavior matches the existing printReceipt() handler;
update only the p:commandButton's value/onclick (and add the new JS function if
choosing the first option).
- Line 103: Add the timeZone attribute to each f:convertDateTime usage so
timestamps are rendered in Asia/Colombo; specifically update every
<f:convertDateTime pattern="dd MMM yyyy HH:mm"/> occurrence to include
timeZone="Asia/Colombo" (i.e., <f:convertDateTime pattern="dd MMM yyyy HH:mm"
timeZone="Asia/Colombo"/>), ensuring all f:convertDateTime tags in the inward
room discharge receipt are changed consistently.
- Around line 10-19: Move the print helper into the page composition head so the
function is defined inside the template-provided <h:head>: relocate the existing
printReceipt() script block from outside the <ui:composition> into the
composition's head section (so onclick handlers can find printReceipt()), add
timeZone="Asia/Colombo" to every f:convertDateTime used for Admission Date,
Admitted At, Discharged At and Printed At (i.e., update each f:convertDateTime
tag to include timeZone="Asia/Colombo"), and fix the Print Previous button so it
no longer calls the same onclick as Print — either change its onclick to a
distinct handler that loads/prints the previous receipt or remove/rename the
button if that feature is not implemented (update the button's onclick attribute
accordingly); ensure references to the print helper use the printReceipt() name
consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1888309b-c48c-4965-8656-1b42c7323b3c
📒 Files selected for processing (8)
src/main/java/com/divudi/bean/common/NotificationController.javasrc/main/java/com/divudi/bean/inward/AdmissionController.javasrc/main/java/com/divudi/bean/inward/RoomChangeController.javasrc/main/java/com/divudi/core/data/TriggerType.javasrc/main/java/com/divudi/core/data/TriggerTypeParent.javasrc/main/webapp/inward/admission_profile.xhtmlsrc/main/webapp/inward/inward_patient_room_details.xhtmlsrc/main/webapp/inward/inward_room_discharge_receipt.xhtml
…ceipt page
- Replace non-existent nameWithInitials with name() on WebUser
- Replace non-existent Person.nameOfAgeAndGender with Person.ageAsString
- Remove broken #{now} EL expression, use loggedUser.name for printed-by
- Remove redundant footer printed-by line
Co-Authored-By: Claude <noreply@anthropic.com>
Self-review fixes pushed (3f96c88)Fixed three runtime errors in the receipt page
No other issues found in review — the TriggerType enum additions preserve ordinal values, all audit paths null-guard appropriately, and privilege names match the existing |
…ement, timezone, button IDs - Fix duplicate audit event logging: set status/duration before single logAuditEvent call - Remove h:head script block outside ui:composition (would not render); inline window.print() - Add timeZone="Asia/Colombo" to all f:convertDateTime in receipt page and dashboard - Rename "Print Previous" to "Print Copy" since previous retrieval not implemented - Add stable id attributes to room-management buttons (btnAddNewRoom, btnAddGuardianRoom, btnRoomDetails, btnRoomChange, btnGuardianRoomChange) - Add JsfUtil error message for failed active room query instead of silent swallow Co-Authored-By: Claude <noreply@anthropic.com>
CodeRabbit review fixes applied (ab55314)All six findings addressed:
|
…ry failure - Use existing logger with Level.SEVERE and admission ID context - Surface recoverable error via JsfUtil.addErrorMessage instead of silent return Co-Authored-By: Claude <noreply@anthropic.com>
…tion Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Discharge Button Fix (#21257)
inward_patient_room_details.xhtmlby switching fromajax="false"to AJAX mode withprocess="@this"andupdate="@form"patientRoomvspRbug inRoomChangeController.dischargeWithCurrentTime()whereindexOfused the List field instead of the method parameterp:confirm) for discharge and cancel actionsdischargedAtfieldDashboard Room Listing
admission_profile.xhtmlRoom Management panel showing current PatientRoom/GuardianRoom assignments with admitted time and View linkgetActivePatientRooms()method toAdmissionControllerRoom Discharge Receipt
inward_room_discharge_receipt.xhtmlpage with Print, Print Previous, and Inpatient Dashboard navigationPrivileges, Audit Logging & Notifications
INWARD_PATIENT_ROOM_ADDED,INWARD_PATIENT_ROOM_CHANGED) with System/SMS/Email variantsNotificationControllerwith notification methods for room admit, room change, and discharge cancelNotification Fixes (#21389, #21390, #21391)
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements
Chores